<?php
include("template_top.php");
?>
<h1>Hardware and Software Loan Center</h1>
<p>
<table width="100%">
	<tr>
    	<?php if(@$_POST['type'] == 'Software'){ ?>
    	<td width="50%">
        	<h4>Check-In Hardware/Software</h4>
            <center>
            	<form action="Hardware_Software_Center.php" method="POST">
		          Receipt ID Number:<br/>
		          <input type="text" name="id" />
		          <br/>
        		  <input type="submit" value="Check-In" />
		        </form>
            </center>
        </td>
        <?php } ?>
        <td>
        	<h4>Check-Out Hardware/Software</h4>
            <?php if(@$_POST['type'] == 'Software'){ ?>
            <form action="Check_Out_Software_Receipt.php" method="POST" target="_blank" onsubmit="window.location = 'Hardware_Software_Center.php';">
            <table width="100%">
            	<tr>
                	<td width="100" align="right">
                    	Software:
                    </td>
                    <td>
                    	<select name="software" style="width:98%">
                        	<option>Microsoft Office Enterprise 2007</option>
                            <option>Microsoft Windows XP</option>
                            <option>Microsoft Office Enterprise 2008 - Mac</option>
                        </select>
                    </td>
                </tr>
            	<tr>
                	<td width="100" align="right">
                    	Software Disc ID:
                    </td>
                    <td>
                    	<input type="text" name="software_id" style="width:97%" />
                    </td>
                </tr>
            	<tr>
                	<td>
                    	<?php foreach($_POST as $key=>$value){ ?>
                    	<input type="hidden" name="<?php echo $key ?>" value="<?php echo $value ?>" />
                        <?php } ?>
                    </td>
                    <td align="right">
                    	<input type="submit" value="Check-Out" />
                    </td>
                </tr>
            </table>
            </form>
            <?php }else{ ?>
            <form action="Check_Out_Hardware_Receipt.php" method="POST" target="_blank" onsubmit="window.location = 'Hardware_Software_Center.php';">
            <table width="100%">
            	<tr>
                	<td width="100" align="right">
                    	Date Due Back:
                    </td>
                    <td>
                    	<input type="text" name="due" style="width:97%" />
                    </td>
                </tr>
            	<tr>
                	<td width="100" align="right">
                    	Purpose:
                    </td>
                    <td>
                    	<input type="text" name="purpose" style="width:97%" />
                    </td>
                </tr>
            	<tr>
                	<td width="100" align="right">
                    	Select Items:
                    </td>
                	<td>
                    	<?php
						$sql = "SELECT * FROM `tbHardware` WHERE `sMain` = 'Y' ORDER BY `iItemID` ASC";
						$q = db::Query($sql);
						while($row = $q->fetch()){
							$sql = "SELECT * FROM `tbLoanLink` WHERE `sItemIdentifier` = :id";
							$query = db::Query($sql, array(':id'=>$row['iItemID']));
							$row2 = $query->fetch();
							if($row2['sItemIdentifier'] == NULL){
								echo "<input type='checkbox' name='".$row['iItemID']."' value='".$row['sDescription']."'> ".$row['iItemID']." - ".$row['sDescription']."<br/>";
							}
						}
						?>
                    </td>
                </tr>
                <tr>
                	<td>
                    	<?php foreach($_POST as $key=>$value){ ?>
                    	<input type="hidden" name="<?php echo $key ?>" value="<?php echo $value ?>" />
                        <?php } ?>
                    </td>
                	<td align="right">
                    	<input type="hidden" name="sType" id="sType" value="" />
                    	<input type="submit" value="Check-Out" />
                        - or - 
                    	<input type="submit" value="Place On Hold" onclick="document.getElementById('sType').value = 'hold';" />
                    </td>
                </tr>
            </table>
            </form>
            <?php } ?>
        </td>
    </tr>
</table>
<h4>Current Hardware and Software Loans</h4>
<table width="100%">
	<tr>
    	<td style="font-weight:bold; border-bottom:solid 1px #666666">Receipt ID</td>
        <td style="font-weight:bold; border-bottom:solid 1px #666666">Last Name, First Name</td>
        <td style="font-weight:bold; border-bottom:solid 1px #666666">Loan Type</td>
        <td style="font-weight:bold; border-bottom:solid 1px #666666">Loan Status</td>
        <td style="font-weight:bold; border-bottom:solid 1px #666666">Date Loaned</td>
        <td style="font-weight:bold; border-bottom:solid 1px #666666">Loaned By</td>
    </tr>
    <?php
	$sql = "SELECT * FROM `tbLoanReceipts` WHERE `sStatus` != 'Returned'";
	$q = db::Query($sql);
	while($row = $q->fetch()){ ?>
    <tr>
    	<td style="border-bottom:solid 1px #666666"><a href="Check_Out_Hardware_Receipt_Reprint.php?id=<?php echo $row['sReceiptId'] ?>" target="_blank"><?php echo $row['sReceiptId'] ?></a></td>
        <td style="border-bottom:solid 1px #666666"><?php echo $row['sLname'].", ".$row['sFname'] ?></td>
        <td style="border-bottom:solid 1px #666666"><?php echo $row['sType'] ?></td>
        <td style="border-bottom:solid 1px #666666"><?php echo $row['sStatus'] ?></td>
        <td style="border-bottom:solid 1px #666666"><?php echo $row['sDate']." @ ".$row['sTime'] ?></td>
        <td style="border-bottom:solid 1px #666666"><?php echo $row['sUname'] ?></td>
    </tr>
    <?php } ?>
</table>
</p>
<?php
include("template_bot.php");
?>